import {Directive, Input, TemplateRef, ViewContainerRef} from '@angular/core';
import {Menu} from "../../models/menu";

@Directive({
  selector: '[appDatavMenu]'
})
export class DatavMenuDirective {

  constructor(
    private templateRef: TemplateRef<any>,
    private viewContainer: ViewContainerRef
  ) { }
  @Input()
  set appDatavMenu(menus:Array<Menu>){
    if(!!menus && menus.length > 0){
      this.viewContainer.createEmbeddedView(this.templateRef);
    }else{
      this.viewContainer.clear();
    }
  }
}
